//
//  mainTabBarViewController.swift
//  Weibo
//
//  Created by dongpeng on 16/1/10.
//  Copyright © 2016年 dongpeng. All rights reserved.
//

import UIKit

class mainTabBarViewController: UITabBarController {

    
   @objc private func plusBtnDidCkick() {
    
//    print(__FUNCTION__)
    
    print(__FUNCTION__)
    
    
    
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
        
        
//        let mainTabbar = mianTabBar()
//        setValue(mainTabbar, forKey: "tabBar")
        
         let mianTabar = mianTabBar()
        
        setValue(mianTabar, forKey: "tabBar")
        
       mianTabar.plusBtn.addTarget(self, action: "plusBtnDidCkick", forControlEvents: .TouchUpInside)
        
        addchildViewcontrollers()
    }

    
    
    func addChiViewContrller(vc:UIViewController, imageName: String, title: String) {
    
    vc.tabBarItem.image = UIImage(named: imageName)
        
     vc.title = title
        
      addChildViewController(UINavigationController(rootViewController: vc))
        
        
        
    
    
    }
    
    
    
    func addchildViewcontrollers() {
        
        //       let VC = HomeTableViewController()
        
        //       let VB = MessageTableViewController()
        //
        //       let VA = DiscoverTableViewController()
        //
        //        let VW = ProflieTableViewController()
        
        
        
        //       VC.title = "首页"
        //
        //       VC.tabBarItem.image = UIImage (named: "tabbar_home")
        //
        //        VB.tabBarItem.image = UIImage (named: "tabbar_message_center")
        //
        //        VA.tabBarItem.image = UIImage (named: "tabbar_discover")
        //
        //        VW.tabBarItem.image = UIImage (named: "tabbar_profile")
        
        //        addChildViewController(HomeTableViewController(),imageName:"")
        
        
        //        addChildViewController(UINavigationController(rootViewController: VC))
        
        //        addChildViewController(HomeTableViewController(UIImage:VB))
        
        tabBar.tintColor = UIColor.orangeColor()
        
        addChiViewContrller(HomeTableViewController(), imageName: "tabbar_home", title: "首页")
        
        addChiViewContrller(MessageTableViewController(), imageName: "tabbar_message_center", title:"消息")
        
        addChiViewContrller(DiscoverTableViewController(), imageName: "tabbar_discover", title: "发现")
        
        addChiViewContrller(ProflieTableViewController(), imageName: "tabbar_profile", title: "我")
        
        
        
        
        
        
        
        
    }

    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

  
}
